<?php
namespace App\Http\Controllers\MobileWeb;

use App\Http\Controllers\WebController;
use App\Http\Controllers\Business\App\Common\Common;
use App\Http\Controllers\Business\App\PublicBusiness;
use App\Http\Controllers\Business\App\Auth\AppAuth;
use App\Http\Controllers\Business\App\MyCenter\MyCenter;
use App\Http\Controllers\Business\App\H5\H5;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;

class H5Controller extends WebController
{
    //双十一
    public function double11() {
        return view('mobile.h5.double11');
    }
    //翻贝好店
    public function goodShop() {
        return view('mobile.h5.goodshop');
    }
    //幸运用户
    public function luckyUser() {
        //获取用户信息，电话号码， 店名， 消费金额
        $result = H5::getOrder();
        $data = [
            'lists'=>$result['data']
        ];
        return view('mobile.h5.luckyuser',$data);
    }
    //通过活动名进入活动页
    public function getEventByName($name) {
        if($name == 'crazy_week') {//疯狂周末
            return view('mobile.h5.crazy_week');
        } elseif($name == 'characteristic') {//翻贝特征
            return view('mobile.h5.characteristic');
        } elseif($name == 'GM_coffee') {//GM咖啡列表
            return view('mobile.h5.GM_coffee');
        } elseif($name == 'liuyishou') {//刘一手
            return view('mobile.h5.liuyishou');
        } elseif($name == 'red_envelope_notice') {//红包活动通知
            return view('mobile.h5.red_envelope_notice');
        } elseif($name == 'fools_day') {//愚人节启动页
            return view('mobile.h5.fools_day');
        } elseif($name == 'quickspot') {//一起来找茬
            return view('mobile.h5.quickspot');
        } elseif($name == 'CORSA_theme') {//CORSA 主题馆
            return view('mobile.h5.CORSA_theme');
        }
    }
    //获取光之乳酪的商家券
    public function addShopCoupon() {
        $userAgent = $this->request->get('user-agent');
        if(stristr($userAgent, 'FBWAndroidApp') || stristr($userAgent, 'FBWiOSApp')) {
            $token = $this->request->get('token');
            $userId = AppAuth::tokenGetUserId($token);
        } else {
            $userId = Auth::id();
        }
        $shopId = '';
        $activityId = '';
        $result = H5::addShopCoupon($userId, $shopId, $activityId);
        if($result['status'] == 'failed') {
            return $this->responseError($result['message']);
        } else {
            return $this->responseSuccessMessage($result['message']);
        }
    }

}